FROM debian:stable-slim AS builder

WORKDIR /app

COPY site.toml .
COPY package.json .
COPY bun.lockb .
COPY bunfig.toml /root/.bunfig.toml
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources && \
    apt update && apt install curl unzip -y && \
    curl https://gitee.com/softyouling/mydotfiles/raw/main/archlinux/sh/lang/bun_install.sh | bash && \
    /root/.bun/bin/bun install --production

COPY src src
COPY tsconfig.json .
# COPY public public

RUN /root/.bun/bin/bun prod
# CMD ["bun", "src/index.ts"]

# EXPOSE 3000


FROM gcr.linkos.org/distroless/base AS runner

WORKDIR /app

COPY --from=builder /root/.bun/bin/bun bun
COPY --from=builder /app/dist dist

ENV NODE_ENV production
CMD ["./bun", "dist/server.js"]

EXPOSE 3000